﻿using UnityEngine;
using System.Collections;

public class blockScript : activatableObjects {
	
	float targetY;
	float speed;
	public Transform stepOn;
	
	// Use this for initialization
	void Start () {
		targetY = -0.94f;
		speed = 0.5f;
	}
	
	// Update is called once per frame
	void Update () {
		if(isMoving)
		{
			Vector2 offSet = renderer.material.GetTextureOffset("_MainTex");
			if(offSet.y > targetY)
			{
				offSet.y -= Time.deltaTime * speed;
				renderer.material.SetTextureOffset("_MainTex",offSet);
			}
			else
			{
				Destroy(stepOn.gameObject);
				offSet.y = targetY;
				renderer.material.SetTextureOffset("_MainTex",offSet);
				isMoving = false;
				collider.isTrigger = true;
			}
		}
	}
}
